﻿//////////////////////////////////////////////////////////////////////////////////
//
// Project            : SilverlightAsyncSave
// Module             : SilverlightAsyncSave
// Description        : Error window.
// 
// Repository         : $URL$
// Last changed by    : $LastChangedBy$
// Revision           : $LastChangedRevision$
// Last Changed       : $LastChangedDate$
// Author             : $Author$
//
// Id                 : $Id$
//
// Copyright          : (c) 2010 Torsten Bär
//
// Published under the MIT License. See license.txt or http://www.opensource.org/licenses/mit-license.php.
//
//////////////////////////////////////////////////////////////////////////////////
using System;
using System.Windows;
using System.Windows.Controls;

namespace SilverlightAsyncSave
{
   /// <summary>
   /// Error window.
   /// </summary>
   public partial class ErrorWindow : ChildWindow
   {
      /// <summary>
      /// Initializes a new instance of the <see cref="ErrorWindow"/> class.
      /// </summary>
      /// <param name="e">The e.</param>
      public ErrorWindow(Exception e)
      {
         InitializeComponent();
         if (e != null)
         {
            ErrorTextBox.Text = e.Message + Environment.NewLine + Environment.NewLine + e.StackTrace;
         }
      }

      /// <summary>
      /// Initializes a new instance of the <see cref="ErrorWindow"/> class.
      /// </summary>
      /// <param name="uri">The URI.</param>
      public ErrorWindow(Uri uri)
      {
         InitializeComponent();
         if (uri != null)
         {
            ErrorTextBox.Text = "Page not found: \"" + uri.ToString() + "\"";
         }
      }

      /// <summary>
      /// Initializes a new instance of the <see cref="ErrorWindow"/> class.
      /// </summary>
      /// <param name="message">The message.</param>
      /// <param name="details">The details.</param>
      public ErrorWindow(string message, string details)
      {
         InitializeComponent();
         ErrorTextBox.Text = message + Environment.NewLine + Environment.NewLine + details;
      }

      /// <summary>
      /// Handles the Click event of the OKButton control.
      /// </summary>
      /// <param name="sender">The source of the event.</param>
      /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
      private void OKButton_Click(object sender, RoutedEventArgs e)
      {
         this.DialogResult = true;
      }
   }
}